<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		var sendFlag=false;
		var id="";
		var wi = 900;
		var hi = 500;
		window.resizeTo(wi + 10, hi + 30);
		$("#closeBtn").click(function(){
			self.close();
		});
		$("#nick").keyup(function(){
			$.ajax({
				type:"post",
				url:"member_ajaxMessageFindByNick.do",
				dataType:"json",
				data:"nick="+$("#nick").val(),
				success:function(jsonData){
					if(jsonData.flag=="true"){
						sendFlag=true;
						id=jsonData.id;
					}else{
						sendFlag=false;
					}
				}
			});
		});
		$("#messageSendBtn").click(function(){
			$("#content").val();
			if($("#content").val()==""){
				alert("내용을 입력하세요");
			}else if($("#nick").val()==""){
				alert("닉네임을 입력하세요");
			}else{
				if(sendFlag==true){
					$.ajax({
						type:"post",
						url:"member_forwardingMessage.do",
						dataType:"json",
						data:"id="+id+"&content="+$("#content").val(),
						success:function(jsonData){
							alert(jsonData);
							location.href="member_getmessage.do";
						}
					});
				}else{
					alert("닉네임이 존재하지 않습니다");
				}
			}
		});
		$("input[id^=getMessageBtn]").click(function(){
			if(confirm("삭제하시겠습니까?"))
			location.href="deleteGetMessage.do?no="+$(this).parent().parent().children().find("input[id^=hiddenNo]").val();
		});
		$("input[id^=sendMessageBtn]").click(function(){
			if(confirm("삭제하시겠습니까?"))
			location.href="deleteSendMessage.do?no="+$(this).parent().parent().children().find("input[id^=hiddenNo]").val();
		});
		$("#messageSendCancelBtn").click(function(){
			location.href="member_getmessage.do";
		});
		$("#inputMessageBtn").click(function(){
			location.href="member_inputMessage.do";
		});
		$("#getMessageListBtn").click(function(){
			location.href="member_getmessage.do";
		});
		$("#sendMessageListBtn").click(function(){
			location.href="member_sendmessage.do";
		});
		
	});
</script>
</head>
<body>
<table border="1" width="100%" height="440"class="box">
	<tr height="90%">
		<td width="15%" align="center">
			<tiles:insertAttribute name = "menu"/>
		</td>
		<td width="85%">
			<tiles:insertAttribute name="main"/>
		</td>
	</tr>
	<tr height="10%">
		<td colspan="2" align="center"><tiles:insertAttribute name="footer"/></td>
	</tr>
</table>
</body>
</html>